package main

import (
	"fmt"
	"context"
	"time"
)


type funcA func()


func funcC(ch chan bool,f1 funcA){

	f1()
	ch <- true

}


func funcB(ctx context.Context,f1 funcA) int {
    ch := make(chan bool,1)
    go funcC(ch,f1)
    select {
    case <- ch :

	    return 1
    case <- ctx.Done() :
           fmt.Println("chaoshi")
	    return 0

    }

}


func do(){

    fmt.Println("do work start")
    time.Sleep(time.Second * 10)
    fmt.Println("do work")

}


func workDo(){
   ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
   funcB(ctx,do)
   cancel()
   fmt.Println("ok")
}

func main(){


  workDo()
}
